<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix = "c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:useBean id="manager" class="beans.AddBean" scope="request" >
	<c:set target="${manager}" property="request" value="${pageContext.request}"></c:set>
	<c:set target="${manager}" property="response" value="${pageContext.response}"></c:set>
</jsp:useBean>
<c:set var="person"  value="${manager.person}" ></c:set>

<c:choose>
	<c:when test="${manager.error}">
		<p>error->${manager.errorstr}</p>
	</c:when>
	<c:otherwise>
		<c:if test="${param.action == 'add'}">
			<c:choose>
		      <c:when test="${manager.addperson}">
		      	<c:redirect url="index.jsp"/>
		      </c:when>
		      <c:otherwise>
				${manager.exception.exceptionCode.value}
		      </c:otherwise>
			</c:choose>
		</c:if>
		
		<c:if test="${param.action == 'cancel'}">
			<c:redirect url="index.jsp"/>
		</c:if>
		
		<jsp:include page="header.jsp" />
		
		<div class="div_center">
			 <form id="addForm" onsubmit="return formIsValid()" method="post" action="">
				<jsp:include page="form.jsp" />
				<input type="submit" formaction="?action=add" name="btnAdd" value="Добавить" />
				
			 </form>
			 <input type="submit" onClick="btnCancelClick()" name="btnCancel" value="Отменить" />
		 </div>
 	</c:otherwise>			
</c:choose> 
 
<jsp:include page="footer.jsp" />